package com.ifeng.igps.action;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;

import com.ifeng.igps.constant.Constant;
import com.ifeng.igps.intentservice.Service;
import com.ifeng.igps.model.GPSPoint;
import com.ifeng.mu.util.MULog;

public class Action {
	private final static String TAG = "Action";
	private Context c;

	public Action(Context c) {
		this.c = c;
	}

	// Intent i = new Intent(c, ServiceMail.class);
	// i.setAction(ConstantMail.MU_MAIL_CONTACT_ADD_TO);
	// i.putExtra("contactName", name);
	// i.putExtra("contactMail", mail);
	// c.startService(i);
	/**
	 * @param email
	 * @param password
	 */
	public void login(String username, String password) {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_LOGIN_TO);
		i.putExtra("username", username);
		i.putExtra("password", password);
		c.startService(i);
	}

	/**
	 * @param username
	 * @param email
	 * @param password
	 */
	public void signUp(String username, String email, String password) {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_SIGNUP_TO);
		i.putExtra("username", username);
		i.putExtra("email", email);
		i.putExtra("password", password);
		c.startService(i);
	}

	public void startRun() {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.RUNNINGMAP_REFRESH_DATA_TO);
		c.startService(i);
	}

	public void saveRunData(String runDate, String totalDistance,
			String timeConsuming, String averageSpeed, String stepsNumber, ArrayList<GPSPoint> al) {
		Intent i = new Intent(c, Service.class);
		i.putExtra("runDate", runDate);
		i.putExtra("totalDistance", totalDistance);
		i.putExtra("timeConsuming", timeConsuming);
		i.putExtra("averageSpeed", averageSpeed);
		i.putExtra("stepsNumber", stepsNumber);
		i.putParcelableArrayListExtra("al", al);
		i.setAction(Constant.RUNNINGMAP_SAVE_DATA_TO);
		c.startService(i);
	}

	public void uploadRun() {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.RUNNINGMAP_UPLOAD_DATA_TO);
		c.startService(i);
	}

	/**
	 * @param birthday
	 * @param weight
	 * @param gender
	 */
	public void saveMyInfo(String gender, String weight, String birthday) {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_SAVEMYINFO_TO);
		i.putExtra("gender", gender);
		i.putExtra("weight", weight);
		i.putExtra("birthday", birthday);
		c.startService(i);
	}

	public void uploadAllRecords() {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_UPLOADALL_TO);
		c.startService(i);
	}

	public void getHomeTotal() {
		MULog.d(TAG, "getHomeTotal");
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_GETHOMETOTAL_TO);
		c.startService(i);
	}

	public void getRunListbyDate(String date) {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_GETRUNLIST_TO);
		i.putExtra("date", date);
		c.startService(i);
	}

	public void getRunRank(int rankby) {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_GETRUNRANK_TO);
		i.putExtra("rankby", rankby);
		c.startService(i);
	}

	public void getAllSteps(String date) {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_GETSTEPSALL_TO);
		i.putExtra("date", date);
		c.startService(i);
	}
	
	public void getRoute(String recordId){
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_GETROUTE_TO);
		i.putExtra("recordId", recordId);
		c.startService(i);
	}

	public void getMyInfo() {
		Intent i = new Intent(c, Service.class);
		i.setAction(Constant.IGPS_GETMYINFO_TO);
		c.startService(i);
	}
}
